Communication device

ABSTRACT

An MFP establishes a first communication link L1 by receiving an activation command and sending an OK command. The MFP receives first target data from a portable device by using the first communication link. The MFP generates second target data by processing the first target data. After receiving the first target data, the MFP disconnects the first communication link. The MFP establishes a second communication link by receiving the activation command and sending the OK command. The MFP sends the second target data to the portable device by using the second communication link.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.15/584,056 filed May 2, 2017 which is a divisional of U.S. patentapplication Ser. No. 13/834,434 filed Mar. 15, 2013, issued as U.S. Pat.No. 9,787,363 on Oct. 10, 2017, which claims priority to Japanese PatentApplication No. 2012-082819, filed on Mar. 30, 2012, the contents ofwhich are hereby incorporated by reference into the present application.

TECHNICAL FIELD

The technology disclosed in the present specification relates to acommunication device that communicates target data that is a target ofcommunication, with an external device according to an NFC (anabbreviation of Near Field Communication) scheme, which is acommunication scheme complying with an NFC standard.

DESCRIPTION OF RELATED ART

A conventional technology used for executing wireless communication bytwo communication devices has been known. In this technology, the twocommunication devices communicate communication information wirelesslyaccording to the NFC scheme. The communication information includesinformation used for executing the wireless communication according to acommunication scheme (such as IEEE 802.11a) different from the NFCscheme (i.e., information indicating the communication scheme,information indicating an encryption scheme). With this technology, thetwo communication devices can execute the wireless communication inaccordance with the communication scheme different from the NFC scheme.

SUMMARY

The present specification provides a technology for allowing acommunication device to appropriately communicate target data that is atarget of communication, with an external device according to the NFCscheme.

In one aspect of the teachings disclosed herein, a communication deviceconfigured to communicate target data that is a target of communicationwith an external device according to an NFC (Near Field Communication)scheme may be provided. The NFC scheme may be a scheme complying with anNFC standard. The communication device may comprise an NFC interfaceconfigured to execute NFC scheme communication; a processor; and amemory configured to store a computer program. According to the computerprogram, the processor may be configured to execute a first establishingstep, a first communicating step, a disconnecting step, a secondestablishing step, and a second communicating step. The firstestablishing step communicates a first establishing command with theexternal device via the NFC interface so as to establish a firstcommunication link between the communication device and the externaldevice. The first communicating step may communicate first target datawith the external device via the NFC interface by using the firstcommunication link. The disconnecting step may disconnect the firstcommunication link after communicating the first target data with theexternal device. The second establishing step may communicate a secondestablishing command with the external device via the NFC interfaceafter disconnecting the first communication link, so as to establish asecond communication link between the communication device and theexternal device. The second communicating step may communicate secondtarget data with the external device via the NFC interface by using thesecond communication link, the second target data being data generatedby processing the first target data.

A non-transitory computer-readable storage medium storing a computerprogram for a communication device configured to communicate target datathat is a target of communication with an external device according toan NFC scheme is also novel and useful.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 shows a configuration of a communication system;

FIG. 2 shows a flowchart of a Listen-process of MFP;

FIG. 3 shows a flowchart following the one shown in FIG. 2;

FIG. 4 shows a flowchart of a Poll-process of MFP;

FIG. 5 shows a flowchart following the one shown in FIG. 4;

FIG. 6 shows a sequence chart of a case A1, which is an example ofcommunication in a P2P-mode;

FIG. 7 shows a sequence chart of a case A2, which is an example ofcommunication in a P2P-mode;

FIG. 8 shows a sequence chart of a case A3, which is an example ofcommunication in a P2P-mode;

FIG. 9 shows a sequence chart of a case A4, which is an example ofcommunication in a P2P-mode;

FIG. 10 shows a sequence chart of a case B1, which is an example ofcommunication in a R/W-mode and communication in a CE-mode;

FIG. 11 shows a sequence chart of a case B2, which is an example ofcommunication in a R/W-mode and communication in a CE-mode; and

FIG. 12 shows a sequence chart of cases B3 to B8, which is an example ofcommunication in a R/W-mode and communication in a CE-mode.

EMBODIMENT

(Configuration of Communication System 2)

As shown in FIG. 1, a communication system 2 has a multi-functionperipheral (“MFP,” hereinafter) 10 and a portable device 50. The MFP 10and the portable device 50 are capable of executing communication inaccordance with a communication scheme (i.e., an NFC scheme) complyingwith the NFC standard. In the present embodiment, the NFC standard isISO/IEC 21481 or ISO/IEC 18092 international standard level. The NFCscheme communication is wireless communication using a radio wave of13.56 MHz band. The MFP 10 and the portable device 50 are each capableof executing wire communication or wireless communication by using acommunication network different from a communication link according tothe NFC scheme.

(Configuration of MFP 10)

The MFP 10 has an operating unit 12, a display unit 14, a networkinterface (described as “I/F,” hereinafter) 16, a print executing unit18, a scan executing unit 20, an NFC I/F 22, and a controller 30. Theoperating unit 12 has a plurality of keys. A user can input variousinstructions to the MFP 10 by operating the operating unit 12. Thedisplay unit 14 is a display for displaying various pieces ofinformation. The network I/F 16 may be an I/F connected to a wirednetwork or an I/F connected to a wireless network. Note that thiswireless network is a network for executing wireless communicationdifferent from the NFC scheme communication, the network complying with,for example, an IEEE (an abbreviation of Institute of Electrical andElectronics Engineers, Inc.) 802.11 standard and a standard equivalentthereto (e.g., 802.11a, 11b, 11g, 11n). The print executing unit 18 isan inkjet or laser printing mechanism. The scan executing unit 20 is ascan mechanism such as a CCD or CIS.

The NFC I/F 22 is an interface for executing the NFC schemecommunication. The NFC I/F 22 is configured by a chip different from thenetwork I/F 16. Note that, in a case where the network I/F 16 is an I/Fconnected to a wireless network, the network I/F 16 and the NFC I/F 22differ from each other in terms of the following points.

In other words, the speed of wireless communication using the networkI/F 16 is higher than the speed of wireless communication using the NFCI/F 22. The frequency of a carrier wave in the wireless communicationperformed using the network I/F 16 is different from the frequency of acarrier wave in the wireless communication performed using the NFC I/F22. When the distance between the MFP 10 and the portable device 50 isapproximately 10 cm or less, the MFP 10 can execute the NFC schemecommunication with the portable device 50 using the NFC I/F 22. On theother hand, even when the distance between the MFP 10 and the portabledevice 50 is equal to or greater than 10 cm, or equal to or less than 10cm, the MFP 10 can execute the wireless communication with the portabledevice 50 using the network I/F 16. In other words, the maximum distancein which the MFP 10 can execute the wireless communication with acommunication-destination device (e.g., the portable device 50) via thenetwork I/F 16 is greater than the maximum distance in which the MFP 10can execute the wireless communication with thecommunication-destination device via the NFC I/F 22. It should be notedthat the wireless communication using the network I/F 16 is referred toas “network wireless communication” hereinafter.

The controller 30 has a CPU 32 and a memory 34. The CPU 32 executesvarious processes in accordance with programs 36, 38 stored in thememory 34. The memory 34 is configured by a ROM, a RAM, a hard disk, andthe like. The memory 34 stores therein the programs 36, 38 that areexecuted by the CPU 32. The application program 36 is a program executedby the CPU 32 to process an application layer of the OSI referencemodel.

The protocol stack 38 is a program executed by the CPU 32 to process alayer lower than the application layer of the OSI reference model. Notethat the protocol stack 38 includes a P2P (an abbreviation of Peer toPeer) program, a R/W program, and a CE program. The P2P program is aprogram for executing a process according to a P2P-mode of the NFCstandard. The R/W program is a program for executing a process accordingto a Reader/Writer-mode of the NFC standard. The CE program is a programfor executing a process according to a CE (an abbreviation of CardEmulation) mode of the NFC standard. These programs are used forexecuting processes complying with the NFC standards defined by the NFCforum.

The memory 34 also stores “0” or “1” as a sending flag. The sending flagindicates whether or not the MFP 10 is to send the target data that is atarget of communication. Specifically, in a situation in which the MFP10 is to send the target data, the sending flag is set at “1.” In asituation in which the MFP 10 is not to send the target data, thesending flag is set at “0.”

The memory 34 also stores “0” or “1” as a communication complete flag.As will be described hereinafter, the NFC scheme communication isperformed between the MFP 10 and the portable device 50 where firsttarget data is sent from one of the devices to the other, and thereafterNFC scheme communication is performed therebetween where second targetdata is sent from the other device to the one device. Hereinafter, thisprocess of executing the communication of the first target data andthereafter the communication of the second target data is referred to as“one set of communication.” The communication complete flag indicateswhether the first target data is communicated or not in the one set ofcommunication. In other words, in a situation in which the first targetdata is communicated, the communication complete flag is set at “1.” Ina situation in which the first target data is not communicated, thecommunication complete flag is set at “0.”

(Configuration of Portable Device 50)

The portable device 50 is, for example, a cellular phone (e.g., asmartphone), a PDA, a laptop, a tablet PC, a portable music reproducer,a portable video reproducer, or the like. The portable device 50 has thenetwork I/F for connecting to the wireless network and the NFC I/F. Theportable device 50 is capable of executing the wireless communicationwith the MFP 10 via either the network I/F or the NFC I/F.

The portable device 50 has an application program (“MFP application,”hereinafter) for causing the MFP 10 to execute various functions (e.g.,a printing function, a scanning function, etc.). Note that the MFPapplication may be installed on the portable device 50 from, forexample, a server provided by a vendor of the MFP 10 or installed on theportable device 50 from a medium shipped along with the MFP 10.

(Target Data that is a Target of Communication)

Various types of data can be considered as the first and second targetdata to be communicated in the one set of communication described above.Examples of the first and second target data are as follows.

First Example

A situation is simulated in which the MFP 10 is to receive print datafrom the portable device 50 to execute the printing function accordingto the print data. The user of the portable device 50 activates the MFPapplication of the portable device 50 and inputs to the portable device50 an instruction for causing the MFP 10 to execute the printingfunction. In this case, the portable device 50 uses the NFC schemecommunication to send the print execution instruction to the MFP 10. Theprint execution instruction does not include the print data.

The MFP 10 receives the print execution instruction from the portabledevice 50 via the NFC I/F 22. As mentioned above, the speed of the NFCscheme communication is lower than the speed of the network wirelesscommunication. For this reason, if the NFC scheme communication is usedfor communicating the print data from the portable device 50 to the MFP10, it might take a long time to communicate the print data. The presentexample, therefore, adopts a configuration in which the MFP 10 receivesthe print data from the portable device 50 by using the network wirelesscommunication. In order to adopt such a configuration, the portabledevice 50 needs to know wireless settings for executing the networkwireless communication with the MFP 10. Thus, when receiving the printexecution instruction from the portable device 50, the MFP 10 sends aresponse including the wireless settings described above to the portabledevice 50 via the NFC I/F 22.

In this manner, the MFP 10 and the portable device 50 can communicatethe print data by executing the network wireless communication in placeof the NFC scheme communication. As a result, the MFP 10 can execute theprinting function. In the present example, the print executioninstruction and the response including the wireless settings are theexamples of “first target data” and “second target data,” respectively.

Second Example

A situation is simulated in which the MFP 10 is to execute the scanningfunction of scanning and generating scan data to send the scan data tothe portable device 50. The user of the portable device 50 activates theMFP application of the portable device 50 and inputs to the portabledevice 50 an instruction for causing the MFP 10 to execute the scanningfunction. In this case, the portable device 50 uses the NFC schemecommunication to send the scan execution instruction to the MFP 10.

The MFP 10 receives the scan execution instruction from the portabledevice 50 via the NFC I/F 22. Similarly to the first example mentionedabove, if the NFC scheme communication is used for communicating theprint data from the MFP 10 to the portable device 50, it might take along time to communicate the scan data. The present example, therefore,adopts a configuration in which the MFP 10 sends the scan data to theportable device 50 by using the network wireless communication. Thus,when receiving the scan execution instruction from the portable device50, the MFP 10 sends a response including the wireless settings to theportable device 50 via the NFC I/F 22.

In this manner, the MFP 10 and the portable device 50 can communicatethe scan data by executing the network wireless communication in placeof the NFC scheme communication. As a result, the MFP 10 can execute thescanning function. In the present example, the scan executioninstruction and the response including the wireless settings are theexamples of “first target data” and “second target data,” respectively.

Third Example

A situation is simulated in which the portable device 50 is to send, tothe MFP 10, setting information to be used by the MFP 10. Examples ofthe setting information include print setting information used when theMFP 10 executes the printing function (e.g., print resolution, papersize, etc.), scan setting information used when the MFP 10 executes thescanning function (e.g., scanning resolution, etc.), and communicationsetting information used when the MFP 10 executes a communicationfunction (e.g., an IP address, subnet mask, gateway address, etc.).

The user of the portable device 50 activates the MFP application of theportable device 50 and inputs to the portable device 50 the settinginformation to be used by the MFP 10. In this case, the portable device50 sends the setting information to the MFP 10 by using the NFC schemecommunication.

The MFP 10 receives the setting information from the portable device 50via the NFC I/F 22. The MFP 10 stores the received setting informationin the memory 34 as the setting information to be used by the MFP 10.Consequently, the MFP 10 can execute various functions by using thereceived setting information. When receiving the setting informationfrom the portable device 50, the MFP 10 sends a response indicating thereceipt of the setting information to the portable device 50 via the NFCI/F 22. In the present example, the setting information and the responseare the examples of the “first target data” and the “second targetdata,” respectively.

Fourth Example

A situation is simulated in which the portable device 50 is to send, tothe MFP 10, address information included in an address book that iscurrently used. The user of the portable device 50 activates the MFPapplication of the portable device 50 and inputs to the portable device50 an instruction for sending the address information to the MFP 10. Inthis case, the portable device 50 sends the address information to theMFP 10 by using the NFC scheme communication.

The MFP 10 receives the address information from the portable device 50via the NFC I/F 22. The MFP 10 adds the received address information tothe address book currently used in the MFP 10 (i.e., the address bookwithin the memory 34). Consequently, the MFP 10 can execute thecommunication function by using the received address information. Whenreceiving the address information from the portable device 50, the MFP10 sends a response indicating the receipt of the address information tothe portable device 50 via the NFC I/F 22. In the present example, theaddress information and the response are the examples of the “firsttarget data” and the “second target data,” respectively.

Fifth Example

The first example described above adopts a configuration in which theMFP 10 sends the print data to the portable device 50 by using thenetwork wireless communication. Instead, for example, the MFP 10 mayreceive the print data from the portable device 50 via the NFC I/F 22.In this case, the MFP 10 may send a response indicating the receipt ofthe print data to the portable device 50 via the NFC I/F 22. In thepresent example, the print data and the response are the examples of the“first target data” and the “second target data,” respectively.

Sixth Example

In the first to fifth examples described above, in the one set ofcommunication the first target data is sent from the portable device 50to the MFP 10 and then the second target data is sent from the MFP 10 tothe portable device 50. However, in the one set of communication, thefirst target data may be sent from the MFP 10 to the portable device 50and then the second target data may be sent from the portable device 50to the MFP 10. For example, the MFP 10 may send scan data to theportable device 50 via the NFC I/F 22 and receive a response from theportable device 50 via the NFC I/F 22. In the present example, the scandata and the response are the examples of the “first target data” andthe “second target data,” respectively.

Note that the combination of the “first target data” and the “secondtarget data” is not limited to those described in the first to sixthexamples and therefore may be a different combination. In other words,the “first target data” may be any type of data as long as the data isthe target of communication, and the “second target data” may also beany type of data as long as the data (i.e., data different from thefirst target data) is generated by processing the first target data. Itshould be noted that a subject generating the second target data may bethe MFP 10 or the portable device 50.

(Modes of NFC Standard)

Each of the modes adopted by the NFC standard is described next.According to the NFC standard, the P2P-mode, the Reader/Writer-Mode(simply described as “R/W-mode” hereinafter), and the CE-mode are used.Note that the devices capable of executing the NFC scheme communication(the MFP 10, the portable device 50, etc.) are referred to as “NFCdevices,” hereinafter.

Among the NFC devices, there exists a device capable of using all of thethree modes, as well as a device capable of using one or two of thethree modes. In the present embodiment, the MFP 10 is the device capableof using all of the three modes. On the other hand, the portable device50 may be capable of using all of the three modes or two of the threemodes such as the R/W-mode and the CE-mode.

(P2P-Mode)

The P2P-mode is a mode for executing bidirectional communication betweena pair of NFC devices. For example, a situation is simulated in which afirst NFC device and a second NFC device are operated according to theP2P-mode. In this case, a communication link for executing communicationaccording to the P2P-mode is established between the first NFC deviceand the second NFC device. For instance, the first NFC device sends datato the second NFC device by using the communication link. Subsequently,the second NFC device normally sends another data to the first NFCdevice by using the same communication link. In this manner, thebidirectional communication is realized. While an NFC device, a tag typeof which defined by the NFC forum is type A, and an NFC device of tagtype F, can be operated according to the P2P-mode, an NFC device of tagtype B cannot be operated according to the P2P-mode.

(R/W-Mode, CE-Mode)

The R/W-mode and the CE-mode are modes for executing unidirectionalcommunication between a pair of NFC devices. The CE-mode is a mode inwhich each of the NFC devices is operated as a “card,” a format definedby the NFC forum. Thereinbelow, such a “card” may be termed a “pseudocard”. The NFC device of the tag type A, the NFC device of the tag typeF, and the NFC device of the tag type B can be operated according to theCE-mode. The R/W mode is also classified into Reader- and Writer-modes.The Reader-mode is a mode for reading data from the NFC devices operatedas the cards in the CE-mode. The Writer-mode is a mode for writing datainto the NFC devices operated as the cards in the CE-mode. Note that, inthe Reader-mode, the data can be read from a card complying with the NFCstandard. Moreover, in the Writer-mode, data can be written into thecard complying with the NFC standard.

For example, a situation is simulated in which the first NFC device isoperated according to the Reader-mode and the second NFC device isoperated according to the CE-mode. In this case, a communication linkfor executing communication according to the Reader-mode and the CE-modeis established between the first NFC device and the second NFC device.The first NFC device executes an operation for reading data from apseudo card of the second NFC device, and thereby receives the data fromthe second NFC device.

For example, a situation is simulated in which the first NFC device isoperated according to the Writer-mode and the second NFC device isoperated according to the CE-mode. In this case, a communication linkfor executing communication according to the Writer-mode and the CE-modeis established between the first NFC device and the second NFC device.The first NFC device executes an operation for writing data in a pseudocard of the second NFC device, and thereby sends the data to the secondNFC device.

As described above, various combinations of the modes can be consideredin order for a pair of NFC devices to execute the NFC schemecommunication. For example, the following five patterns can beconsidered as a combination of the modes of the MFP 10 and the portabledevice 50: “P2P-mode, P2P-mode,” “Reader-mode, CE-mode,” “Writer-mode,CE-mode,” “CE-mode, Reader-mode,” and “CE-mode, Writer-mode.”

(Poll-Operation and Listen-Operation)

The NFC devices are capable of executing a Poll-operation and aListen-operation. More specifically, in the MFP 10, for example, insteadof causing the CPU 32 to execute the Poll-operation and theListen-operation in accordance with the programs 36, 38, the NFC I/F 22executes the Poll-operation and the Listen-operation. The Poll-operationis an operation for sending a polling signal and receiving a responsesignal responsive to the polling signal. The Listen-operation is anoperation for receiving a polling signal and sending a response signalresponsive to the polling signal.

The NFC I/F 22 of the MFP 10 is capable of being operated in any of thefollowing modes: a Poll-mode for executing the Poll-operation, aListen-mode for executing the Listen-operation, and a mode for executingneither the Poll-operation nor the Listen-operation (referred to as“no-execution mode,” hereinafter). The NFC I/F 22 is operated in thePoll-mode, the Listen-mode, and the no-execution mode sequentially. Forexample, the NFC I/F 22 executes one set of operations in which theoperations are performed in the Poll-mode, subsequently in theListen-mode, and then in the no-execution mode. The NFC I/F 22repeatedly executes this one set of operations.

In the Poll-mode, the NFC I/F 22 sends a polling signal and monitorsreceipt of a response signal. Specifically, the NFC I/F 22 (1) sends apolling signal to which the NFC device of the tag type A can respond(i.e., a polling signal corresponding to the type A), and monitorsreceipt of a response signal for a predetermined period of time. (2)When not receiving the response signal, the NFC I/F 22 sends a pollingsignal to which the NFC device of the tag type B can respond (i.e., apolling signal corresponding to the type B), and monitors receipt of aresponse signal for a predetermined period of time. (3) When notreceiving the response signal, the NFC I/F 22 sends a polling signal towhich the NFC device of the tag type F can respond (i.e., a pollingsignal corresponding to the type F), and monitors receipt of a responsesignal for a predetermined period of time. The NFC I/F 22 repeats theseoperations. When the NFC I/F 22 receives the response signal from any ofthe NFC devices within a predetermined period of time, this NFC deviceis considered the type of NFC device corresponding to the polling signalthat is received immediately before the response signal is sent. Whenreceiving the response signal, the NFC I/F 22 further sends an inquirysignal to the NFC device to inquire in which mode the NFC device, towhich the response signal is sent, can be operated. As a result, the NFCI/F 22 receives an operable mode signal from this NFC device. Theoperable mode signal indicates that the NFC device can be operated inthe P2P-mode and the CE-mode or that the NFC device can be operated onlyin the CE-mode.

In the Listen-mode, the NFC I/F 22 monitors receipt of a polling signal,and, when receiving the polling signal, sends a response signal. Onlywhen receiving the type of polling signal corresponding to the NFC I/F22, the NFC I/F 22 sends a response signal to the NFC device that hadsent the polling signal. When sending the response signal to the NFCdevice, the NFC I/F 22 receives the inquiry signal from the NFC deviceand sends the operable mode signal to the NFC device. In theno-execution mode, the NFC I/F 22 does not send a polling signal, anddoes not send a response signal even when a polling signal is received.

The portable device 50 also repeatedly executes the one set ofoperations described above. Therefore, when, for example, the distancebetween the MFP 10 and the portable device 50 is less than 10 cm and aperiod during which the NFC I/F 22 is operated in the Poll-mode isequivalent to a period during which the portable device 50 is operatedin the Listen-mode, the NFC I/F 22 executes the Poll-operation ofsending a polling signal to the portable device 50 and receiving aresponse signal from the portable device 50. Furthermore, when, forexample, the distance between the MFP 10 and the portable device 50 isless than 10 cm and a period during which the NFC I/F 22 is operated inthe Listen-mode is equivalent to a period during which the portabledevice 50 is operated in the Poll-mode, the NFC I/F 22 executes theListen-operation of receiving a polling signal from the portable device50 and sending a response signal to the portable device 50.

Once the NFC I/F 22 executes the Poll-operation or the Listen-operation,each of processes required for performing the subsequent communicationis succeeded to the CPU 32. Specifically, when the NFC I/F 22 of the MFP10 executes the Poll-operation and the portable device 50 executes theListen-operation, information indicating the operation of a certain modethat can be executed by the portable device 50 (i.e., informationindicated by a receipt complete operable mode signal) is delivered fromthe NFC I/F 22 to the CPU 32. Based on the information delivered fromthe NFC I/F 22, the CPU 32 determines in which mode the MFP 10 is to beoperated. Specifically, in a case where the MFP 10 can be operated inany of the modes and the receipt complete operable mode signal indicatesthe operability in the P2P-mode and the CE-mode, the CPU 32 determinesthat the MFP 10 is to be operated in the P2P-mode. In this case in amodification, the CPU 32 may determine that the MFP 10 is to be operatedin the CE-mode. Moreover, when the MFP 10 can be operated in any of themodes and the receipt complete operable mode signal indicates theoperability only in the CE-mode, the CPU 32 determines that the MFP 10is to be operated in the R/W-mode. Suppose that the MFP 10 can beoperated only in the R/W mode and that the receipt complete operablemode signal indicates the operability in the CE-mode, the CPU 32determines that the MFP 10 is to be operated in the R/W-mode. Althoughdescribed hereinafter in detail, the CPU 32 subsequently sends anactivation command to the portable device 50. The activation commandcorresponds to the mode in which the MFP 10 is to be operated (i.e., themode determined by the CPU 32) (see S112 in FIG. 4 and S160 in FIG. 5).The activation command is a command adopted according to the NFCstandard and is used for establishing a communication link according tothe NFC scheme between the MFP 10 and the portable device 50.

Note that the NFC device executing the Poll-operation (referred to as“Poll device,” hereinafter) can be operated in the P2P-mode and theR/W-mode in accordance with the NFC standard but cannot be operated inthe CE-mode. Therefore, when the MFP 10 is the Poll device, the CPU 32determines that the MFP 10 is to be operated in the P2P-mode or the R/Wmode, as described above.

On the other hand, when the NFC I/F22 of the MFP 10 executes theListen-operation and the portable device 50 executes the Poll-operation,the CPU 32 receives the activation command from the portable device 50.The activation command corresponds to the mode in which the portabledevice 50 is to be operated (see S10 in FIG. 2). When receiving theactivation command corresponding to the P2P-mode, the CPU 32 determinesthat the MFP 10 is to be operated in the P2P-mode. When receiving theactivation command corresponding to the R/W-mode, the CPU 32 determinesthat the MFP 10 is to be operated in the CE-mode.

Note that the NFC device executing the Listen-operation (referred to as“Listen device,” hereinafter) can be operated in the P2P-mode and theCE-mode in accordance with the NFC standard but cannot be operated inthe R/W-mode. Therefore, when the MFP 10 is the Listen device, the CPU32 determines that the MFP 10 is to be operated in the P2P-mode or theCE-mode, as described above.

As long as the NFC I/F 22 executes the Poll-operation or theListen-operation as described above, the CPU 32 can find out not onlythat the portable device 50 exists in the vicinity of the MFP 10, butalso that in which mode the MFP 10 is to be operated. The CPU 32 thenexecutes each of the processes required for performing the subsequentcommunication (see FIGS. 2 to 5 described hereinafter).

(Processes Executed by MFP 10; FIGS. 2 to 5)

Processes executed by the MFP 10 are described next with reference toFIGS. 2 to 5. Note that the CPU 32 executes each of the processes shownin FIGS. 2 to 5 in accordance with the programs 36, 38 stored in thememory 34. First of all, contents of processes that are executed by theCPU 32 when the NFC I/F 22 executes the Listen-operation (FIGS. 2 and 3;referred to as “Listen-process of MFP,” hereinafter) are described, andthen contents of processes that are executed by the CPU 32 when the NFCI/F 22 executes the Poll-operation (FIGS. 4 and 5; referred to as“Poll-process of the MFP,” hereinafter) are described.

(Listen-Process of MFP; FIGS. 2 and 3)

As described above, in a case where the NFC I/F 22 executes theListen-operation (i.e., the portable device 50 executes thePoll-operation), the portable device 50 sends the activation command tothe MFP 10. The activation command corresponds to the mode in which theportable device 50 is to be operated. In S10, the CPU 32 receives theactivation command from the portable device 50 via the NFC I/F 22.

Next, in S12, the CPU 32 determines whether the MFP 10 is to be operatedin the P2P-mode or the CE-mode. As described above, the MFP 10 is theNFC device capable of using all of the three modes: namely, theP2P-mode, the R/W-mode, and the CE-mode. On the other hand, the portabledevice 50 may be a device capable of using all of the three modes, or adevice capable of using only the R/W-mode and the CE-mode. Whenreceiving the activation command corresponding to the P2P-mode, the CPU32 determines that the MFP 10 is to be operated in the P2P-mode (YES inS12 of FIG. 2) and proceeds to S14. On the other hand, when receivingthe activation command corresponding to the R/W mode, the CPU 32determines that the MFP 10 is to be operated in the CE-mode (NO in S12of FIG. 2) and proceeds to S62 shown in FIG. 3.

(Listen-Process of MFP; P2P-Mode)

In S14, the CPU 32 sends a response command (i.e., an OK command) to theportable device 50 via the NFC I/F 22 responsive to the activationcommand. Consequently, the communication link according to the NFCscheme is established between the MFP 10 and the portable device 50. Inother words, the CPU 32 can appropriately establish the communicationlink by receiving the activation command and sending the OK command.

Note that, in the Listen-process of MFP, the activation command cannotbe sent from the MFP 10 to the portable device 50. This is because thePoll device can send the activation command, but the Listen devicecannot send the activation command.

Next, in S16, the CPU 32 starts a confirming command responding process.A confirming command is sent from the Poll device to the Listen deviceto confirm whether or not to maintain the communication link. Asdescribed above, the MFP 10 is the Listen device and the portable device50 the Poll device at the present moment. Thus, in the confirmingcommand responding process, the CPU 32 receives the confirming commandfrom the portable device 50 via the NFC I/F 22 and sends a responsecommand (i.e., an OK command) to the portable device 50 via the NFC I/F22 responsive to the confirming command.

Although not shown in the flowcharts, once the CPU 32 starts theconfirming command responding process in S16, the CPU 32 continues theexecution of the confirming command responding process until S38described hereinafter is executed or until the communication link isdisconnected in S44 described hereinafter.

Next, in S18, the CPU 32 determines whether the sending flag stored inthe memory 34 is set at “1” or not. In the one set of communicationdescribed above, in a situation where the first target data is notcommunicated, the sending flag is normally set at “0.” For example, inthe first to fifth examples relating to the target data, the firsttarget data is sent from the portable device 50 to the MFP 10 and thesecond target data is sent from the MFP 10 to the portable device 50. Inthis case, in a situation in which the first target data is notcommunicated, the sending flag is normally set at “0.” As a result, theMFP 10 can receive the first target data from the portable device 50(see S22 and the like). In addition, in such a case, in a situation inwhich the first target data is communicated, the sending flag is set at“1” (see S28 and the like). As a result, the MFP 10 can send the secondtarget data to the portable device 50, as described hereinafter (see S32and the like).

However, in the sixth example relating to the target data, the firsttarget data is sent from the MFP 10 to the portable device 50 and thesecond target data is sent from the portable device 50 to the MFP 10.For instance, when the scan data (i.e., the first target data) isgenerated in accordance with the sixth example described above, the CPU32 changes the sending flag from “0” to “1” in a process not shown inany of the flowcharts of FIGS. 2 to 5. In such a case, even in asituation in which the first target data is not communicated in the oneset of communication described above, the sending flag is set at “1.” Asa result, the MFP 10 can send the first target data to the portabledevice 50, as described hereinafter (see S32 and the like). Furthermore,in such a case, in a situation in which the first target data iscommunicated, the sending flag is set at “0” (see S36 and the like). Asa result, the MFP 10 can receive the second target data from theportable device 50, as described hereinafter (see S22 and the like).

When the sending flag stored in the memory 34 is “1,” the CPU 32determines that the result of S18 is YES and proceeds to S30. On theother hand, when the sending flag stored in the memory 34 is “0,” theCPU 32 determines that the result of S18 is NO and proceeds to S20.

In S20, the CPU 32 executes negotiation with the portable device 50 viathe NFC I/F 22. Specifically, the CPU 32 first determines that the MFP10 is operated as a client of the P2P-mode. The CPU 32 then executescommunication according to a Simple NDEF Exchange protocol such that theMFP 10 is operated as the client and the portable device 50 as a serverof the P2P-mode. Consequently, the portable device 50 is operated as theserver that executes processes in response to requests from the client(i.e., the MFP 10). Note that NDEF is an abbreviation of “NFC DataExchange Format.”

In S20, the CPU 32 further informs the portable device 50 that the MFP10 executes data reception (i.e., that the portable device 50 executesdata sending). This allows the portable device 50 to know that thetarget data is to be sent to the MFP 10, and sends the target data tothe MFP 10. Hereinafter, “target data” may correspond to the firsttarget data or the second target data described in any of the first tosixth examples relating to the target data.

Next, in S22, the CPU 32 receives the target data from the portabledevice 50 via the NFC I/F 22 by using the communication link establishedin S14.

Subsequently, in S24, the CPU 32 processes the target data received inS22. For instance, in the first or second example described above, theCPU 32 interprets a print execution instruction or scan instruction(i.e., the first target data) received in S22, to generate a responseincluding wireless settings (i.e., the second target data).Additionally, in the third example described above, for instance, theCPU 32 stores the setting information received in S22 (i.e., the firsttarget data) in the memory 34 and generates a response indicating thereceipt of the setting information (i.e., the second target data). Inthe fourth example described above, for instance, the CPU 32 addsaddress information received in S22 (i.e., the first target data) to anaddress book of the memory 34 and generates a response indicating thereceipt of the address information (i.e., the second target data). Inthe fifth example described above, for instance, the CPU 32 executes theprinting function in accordance with the print data received in S22(i.e., the first target data) and generates a response indicating thereceipt of the print data (i.e., the second target data).

For instance, in the sixth example described above, the CPU 32interprets the response received in S22 (i.e., the second target data)and confirms that the portable device 50 has received the scan data. Inthis case, unlike in the first to fifth examples described above, theCPU 32 does not execute the process for generating the second targetdata. In other words, the second target data is the data generated bythe portable device 50.

Subsequently, in S26 the CPU 32 determines whether the communicationcomplete flag stored in the memory 34 is set at “1” or not. When thecommunication complete flag stored in the memory 34 is “1,” the CPU 32determines that the result of S26 is YES and proceeds to S40. When, onthe other hand, the communication complete flag stored in the memory 34is “0,” the CPU 32 determines that the result of S26 is NO and proceedsto S28.

In S28, the CPU 32 sets the sending flag stored in the memory 34 at “1”and sets the communication complete flag stored in the memory 34 at “1.”The CPU 32 then proceeds to S38 after S28 is ended.

In S38, the CPU 32 executes a disconnecting process for disconnectingthe communication link established in S14. Two methods can be consideredas a method for the disconnecting process of S38: a software-baseddisconnecting process and a hardware-based disconnecting process. TheCPU 32 may execute either one of the methods for the disconnectingprocess.

In a case where the CPU 32 executes the software-based disconnectingprocess, the CPU 32 ends the confirming command responding process thatis started in S16. In other words, even when the confirming command isreceived from the portable device 50, the CPU 32 does not send aresponse command (i.e., an OK command) responsive to the confirmingcommand to the portable device 50. Therefore, the portable device 50 canfind out that the MFP 10 does not wish to maintain the communicationlink, and sends to the MFP 10 a deactivation command to disconnect thecommunication link.

The CPU 32, therefore, receives the deactivation command from theportable device 50 via the NFC I/F 22. In this case, the CPU 32 sends aresponse command (i.e., an OK command), responsive to the deactivationcommand, to the portable device 50 via the NFC I/F 22. As a result, thecommunication link established in S14 is disconnected. The CPU 32 canappropriately disconnect the communication link by executing thesoftware-based disconnecting process (ending the confirming commandresponding process, receiving the activation command, sending the OKcommand).

Note that the deactivation command cannot be sent from the MFP 10 to theportable device 50 in the Listen-process of MFP. This is because whilethe Poll device can send the deactivation command, the Listen devicecannot send the deactivation command.

On the other hand, in a case where the CPU 32 executes thehardware-based disconnecting process, the CPU 32 temporarily stops theoperations of the NFC I/F 22. More specifically, for example, the CPU 32sends to the NFC I/F 22 an instruction for stopping the operations ofthe NFC I/F 22. Consequently, the NFC I/F 22 temporarily stops all ofthe operations including receiving/sending signals from/to the outside,the Poll-operation, and the Listen-operation. The CPU 32, therefore, canno longer use the NFC I/F 22 to execute the confirming commandresponding process that was started in S16.

Once the hardware-based disconnecting process is executed, the portabledevice 50 cannot receive a response command (i.e., an OK command)responsive to the confirming command, as with the case of thesoftware-based disconnecting process. In this case, the portable device50 sends the deactivation command to the MFP 10 but cannot receive aresponse command (i.e., an OK command) responsive to the deactivationcommand because the operations of the NFC I/F 22 of the MFP 10 arestopped. The portable device 50, therefore, determines this situation asa timeout and ends the process of maintaining the communication link(i.e., the process for sending the confirming command, etc.). As aresult, the communication link established in S14 is disconnected. TheCPU 32 can appropriately disconnect the communication link by executingthe hardware-based disconnecting process (i.e., stopping the operationsof the NFC I/F 22).

Note that the method of stopping the operations of the NFC I/F 22 is notlimited to the method of sending the instruction from the CPU 32 to theNFC I/F 22 described above. For example, the CPU 32 may temporarily stopthe operations of the NFC I/F 22 by temporarily stopping supplying powerto the NFC I/F 22. This method is also an example of the hardware-baseddisconnecting process. Once S38 is ended, the Listen-process of MFP isended.

On the other hand, when the result of S18 is YES (i.e., when the sendingflag is “1”), in S30 the CPU 32 executes the negotiation, as with S20,such that the MFP 10 is operated as the client of the P2P-mode and theportable device 50 as the server of the P2P-mode. In S30, the CPU 32also informs the portable device 50 of that the MFP 10 executes datasending (i.e., that the portable device 50 executes data reception).Consequently, the portable device 50 waits until receiving the targetdata from the MFP 10.

Next, in S32 the CPU 32 sends the target data to the portable device 50via the NFC I/F 22 by using the communication link established in S14.For example, in the first to fifth examples described above, the CPU 32processes the first target data to generate the second target data in,for example, S24 of the previous Listen-process of MFP or S124 of theprevious Poll-process of MFP (FIG. 4). In this case, in S32 the CPU 32sends the generated second target data to the portable device 50.Furthermore, in the sixth example described above, for instance, scandata is generated as the first target data. In this case, in S32 the CPU32 sends the generated first target data to the potable device 50.

Next, in S34 the CPU 32 determines whether the communication completeflag stored in the memory 34 is set at “1” or not. When thecommunication complete flag stored in the memory 34 is set at “1,” theCPU 32 determines that the result of S34 is YES and proceeds to S40.When, on the other hand, the communication complete flag stored in thememory 34 is set at “0,” the CPU 32 determines that the result of S34 isNO and proceeds to S36.

In S36 the CPU 32 sets the sending flag stored in the memory 34 at “0”and the communication complete flag stored in the memory 34 at “1.” OnceS36 is ended, the CPU 32 proceeds to S38 to execute the disconnectingprocess described above.

On the other hand, in S40 the CPU 32 sets the sending flag stored in thememory 34 at “0” and the communication complete flag stored in thememory 34 at “0”.

Note that, when S40 is executed (i.e., when the communication completeflag is set at “1”), communication of the second target data iscompleted (i.e., the one set of communication described above iscompleted). The portable device 50, therefore, determines that it is nolonger necessary to maintain the communication link, and sends thedeactivation command to the MFP 10. As a result, in S42 the CPU 32receives the deactivation command from the portable device 50 via theNFC I/F 22.

Next, in S44 the CPU 32 sends a response command (i.e., an OK command)to the portable device 50 via the NFC I/F 22 responsive to thedeactivation command. As a result, the communication link established inS14 is disconnected. Once S44 is ended, the Listen-process of MFP isended.

(Listen-Process of MFP; CE-Mode (FIG. 3))

Contents of processes that are executed when the result of S12 of FIG. 2is determined as NO (when it is determined that the MFP 10 is to beoperated in the CE-mode) are described next with reference to FIG. 3.The step S62 is same as S14 shown in FIG. 2. Note that, when the MFP 10is operated in the CE-mode and the portable device 50 is operated in theR/W-mode, the confirming code responding process (see S16 of FIG. 2) isnot executed, unlike the case of the P2P-mode. This is because it is notnecessary to confirm whether to maintain the communication link or not,since this mode is for unidirectional communication (i.e., the mode inwhich the target data is communicated only once).

The steps S64 to S72 are same as S18 and S22 to S28 shown in FIG. 2. Thesteps S74 to S78 are same as S32 to S36 shown in FIG. 2. The steps S86to S90 are same as S40 to S44 shown in FIG. 2. Once S90 is ended, theListen-process for MFP is ended.

In S80, the CPU 32 executes the software-based disconnecting process fordisconnecting the communication link established in S62. In other words,the CPU 32 receives the deactivation command from the portable device 50via the NFC I/F 22 and sends a response command (i.e., an OK command) tothe portable device 50 via the NFC I/F 22 responsive to the deactivationcommand. As a result, the communication link established in S62 isdisconnected. The CPU 32 can appropriately disconnect the communicationlink by executing the software-based disconnecting process (receivingthe deactivation command and sending the OK command).

Next, in S82 the CPU 32 executes an operation controlling process forcontrolling the operations of the NFC I/F 22. The CPU 32 sends aninstruction for stopping the operations of the NFC I/F 22 to the NFC I/F22. Consequently, the NFC I/F 22 temporarily stops all of the operationsincluding receiving/sending signals from/to the outside, thePoll-operation, and the Listen-operation.

Once the communication link is disconnected in S80, the portable device50 is operated again in the Poll-mode and the Listen-mode sequentially.However, because the operations of the NFC I/F 22 of the MFP 10 aretemporarily stopped in S82, the portable device 50 does not receive aresponse signal even if the polling signal is sent. The portable device50 also does not receive the polling signal from the MFP 10. For thisreason, the portable device 50 can detect that the distance between theMFP 10 and the portable device 50 has increased, i.e., the communicationcounterpart has seceded.

The reasons that the portable device 50 is caused to detect thesecession of the communication counterpart (i.e., that the operationcontrolling process is executed in S82) are as follows. Thecommunication links corresponding to the CE-mode and the R/W-mode areestablished under the assumption that the target data is communicatedonly once. Thus, when a pair of NFC devices communicates the target datain accordance with the CE-mode and the R/W-mode, normally thecommunication link is disconnected. Subsequently, supposedly when thepair of NFC devices remains close to each other, the pair of NFC devicescan execute the Poll-operation and the Listen-operation again,reestablish the communication link, and communicate the same targetdata. In other words, when the pair of NFC devices remains close to eachother, the same target data is communicated for a number of times.

Therefore, when the secession of the communication counterpart is notdetected after the communication links corresponding to the CE-mode andthe R/W mode are disconnected, the NFC devices are normally programmedso as not to reestablish a communication link even upon executing thePoll-operation and the Listen-operation again. When, for example, theresponse signal is not received from the communication counterpart nomatter how many times the polling signal is sent, or when the pollingsignal is not received from the communication counterpart for apredetermined period of time, the NFC devices detect the secession ofthe communication counterpart. By detecting the secession of thecommunication counterpart in this manner, the NFC devices canreestablish a communication link with the same communicationcounterpart.

In the present embodiment, communication of the second target data isexecuted (i.e., the one set of communication is executed) subsequent tothe communication of the first target data. Therefore, it is necessaryto adopt a mechanism for reestablishing a new communication link forcommunicating the second data, even when the MFP 10 and the portabledevice 50 remain close to each other after the communication link forcommunicating the first target data is disconnected. This mechanism isthe operation controlling process of S82. In other words, by causing theMFP 10 to execute the operation controlling process of S82, the portabledevice 50 can detect secession of the MFP 10, even when the MFP 10 andthe portable device 50 remain close to each other. Thereafter, acommunication link can be reestablished between the MFP 10 and theportable device 50 as long as the MFP 10 and the portable device 50execute the Poll-operation and the Listen-operation.

Note that the operation controlling process of S82 is not limited to themethod of sending an instruction from the CPU 32 to the NFC I/F 22described above. For instance, the CPU 32 may temporarily stop theoperations of the NFC I/F 22 by temporarily stopping supplying power tothe NFC I/F 22. This method is also an example of the operationcontrolling process. Once S82 is ended, the Listen-process of MFP isended.

(Poll-Process of MFP; FIGS. 4 and 5)

Contents of the Poll-process of MFP are described hereinafter withreference to FIGS. 4 and 5. As described above, when the NFC I/F 22executes the Poll-operation, the MFP 10 is operated in either theP2P-mode or the R/W-mode in accordance with the received operable modesignal. In S110, based on the received operable mode signal, the CPU 32determines whether the MFP 10 is to be operated in the P2P-mode or theR/W mode. When it is determined that the MFP 10 is to be operated in theP2P-mode (YES in S110), the CPU 32 proceeds to S112. When it isdetermined that the MFP 10 is to be operated in the R/W-mode (NO inS110), the CPU 32 proceeds to S160 shown in FIG. 5.

(Poll-Process of MFP; P2P-mode (FIG. 4))

In S112, the CPU 32 sends the activation command corresponding to theP2P-mode to the portable device 50 via the NFC I/F 22. Next, in S114,the CPU 32 receives a response command (i.e., an OK command), responsiveto the activation command, from the portable device 50 via the NFC I/F22. As a result, an NFC scheme communication link is established betweenthe MFP 10 and the portable device 50.

Next, in S116, the CPU 32 starts a confirming command sending process.In the confirming command sending process, the CPU 32 sends theconfirming command to the portable device 50 via the NFC I/F 22 andreceives a response command (i.e., an OK command), responsive to theconfirming command, from the portable device 50 via the NFC I/F 22. Notethat, once the CPU 32 starts the confirming command sending process inS116, the CPU 32 continues the execution of the confirming commandsending process until S138 described hereinafter is executed or untilthe communication link is disconnected in S144 described hereinafter.

The steps S118 to S128 are same as S18 to S28 shown in FIG. 2. The stepsS130 to S136 are same as S30 to S36 shown in FIG. 2. The step S140 issame as S40 shown in FIG. 2. In S142, the CPU 32 sends the deactivationcommand to the portable device 50 via the NFC I/F 22. Next, in S144, theCPU 32 receives a response command (i.e., an OK command), responsive tothe deactivation command, from the portable device 50 via the NFC I/F22. As a result, the communication link established in S114 isdisconnected.

In S138, the CPU 32 executes a disconnecting process for disconnectingthe communication link established in S114. Two methods can beconsidered as a method for the disconnecting process of S138: asoftware-based disconnecting process and a hardware-based disconnectingprocess. The CPU 32 may execute either one of the methods for thedisconnecting process.

In a case where the CPU 32 executes the software-based disconnectingprocess, the CPU 32 sends a deactivation command to the portable device50 via the NFC I/F 22 and receives a response command (i.e., an OKcommand) from the portable device 50 via the NFC I/F 22 responsive tothe deactivation command. As a result, the communication linkestablished in S114 is disconnected. The CPU 32 can appropriatelydisconnect the communication link by executing the software-baseddisconnecting process (sending the deactivation command and receivingthe OK command).

Note that the software-based disconnecting process is not limited to themethod of sending the deactivation command from the CPU 32 describedabove. For instance, the CPU 32 may end the confirming command sendingprocess started in S116. In other words, the CPU 32 does not send theconfirming command to the portable device 50. When not receiving theconfirming command from the MFP 10 for a predetermined period of time,the portable device 50 determines this situation as a timeout. Theportable device 50 consequently ends the process relating to thecommunication link (i.e., monitoring reception of the confirmingcommand), resulting in disconnecting the communication link. This methodis also an example of the software-based disconnecting process.

On the other hand, in a case where the CPU 32 executes thehardware-based disconnecting process, the CPU 32 temporarily stops theoperations of the NFC I/F 22. More specifically, for example, the CPU 32sends to the NFC I/F 22 an instruction for stopping the operations ofthe NFC I/F 22. The CPU 32, therefore, can no longer use the NFC I/F 22to execute the confirming command responding process that is started inS116. In this case, the portable device 50 determines this situation asa timeout and ends the process relating to the communication link (i.e.,monitoring reception of the confirming command), resulting indisconnecting the communication link. The CPU 32 can appropriatelydisconnect the communication link by executing the hardware-baseddisconnecting process (i.e., stopping the operations of the NFC I/F 22).

Note that the method of stopping the operations of the NFC I/F 22 is notlimited to the method of sending the instruction from the CPU 32 to theNFC I/F 22 described above. For example, the CPU 32 may temporarily stopthe operations of the NFC I/F 22 by temporarily stopping supplying powerto the NFC I/F 22. This method is also an example of the hardware-baseddisconnecting process. Once S138 is ended, the Listen-process of MFP isended.

(Poll-Process of MFP; R/W-Mode (FIG. 5))

Contents of processes that are executed when the result of S110 of FIG.4 is determined as NO (when it is determined that the MFP 10 is to beoperated in the R/W-mode) are described next with reference to FIG. 5.The steps S160 to S164 are same as S112, S114, and S118 shown in FIG. 4.In S160, however, the CPU 32 sends the activation command correspondingto the RAY-mode.

When the result of S164 is NO (i.e., when the sending flag is set at“0”), the CPU 32 determines in S165 that the MFP 10 is to be operatedaccording to the Reader-mode. Accordingly, the CPU 32 can read thetarget data from the pseudo card of the portable device 50, that is,receive the target data from the portable device 50. The steps S166 toS172 that are executed subsequently are same as S66 to S72 shown in FIG.3.

On the other hand, when the result of S164 is YES (i.e., when thesending flag is set at “1”), the CPU 32 determines in S173 that the MFP10 is to be operated according to the Writer-mode. The CPU 32 thereforecan write the target data into the pseudo card of the portable device50, that is, send the target data to the portable device 50. The stepsS174 to S182 that are executed subsequently are same as S74 to S82 shownin FIG. 3. Note that S186 to S190 are same as S140 to S144 shown in FIG.4.

(Specific Cases)

Specific cases realized by the present embodiment are described next.Each of the following cases is realized by allowing the MFP 10 toexecute each of the processes shown in FIGS. 2 to 5.

(Case A1; FIG. 6)

In the case A1, the MFP 10 executes the Listen-operation (i.e., theportable device 50 executes the Poll-operation) and the portable device50 can be operated according to the P2P-mode.

The MFP 10 receives the activation command from the portable device 50(S10 of FIG. 2) and sends an OK command to portable device 50 (S14).Consequently, a communication link L1 is established between the MFP 10and the portable device 50. In this case, the MFP 10 starts theconfirming command responding process (S16). In other words, the MFP 10receives the confirming command from the portable device 50 and sends anOK command to the portable device 50.

In the case A1, the sending flag is set at “0” at the time of theestablishment of the communication link L1. In this case, the MFP 10determines that the result of S18 of FIG. 2 is NO, executes thenegotiation subsequently, and then informs the portable device 50 ofthat the MFP 10 executes data reception (S20). The MFP 10 receives thefirst target data from the portable device 50 (S22) and generates thesecond target data by processing the first target data (S24). In thiscase, the MFP 10 sets the sending flag at “1” and the communicationcomplete flag at “1” (S28).

Next, the MFP 10 executes the software-based disconnecting process(S38). In other words, the MFP 10 does not send an OK command even whenreceiving the confirming command from the portable device 50. In thiscase, the MFP 10 receives the deactivation command from the portabledevice 50 and sends an OK command to the portable device 50. As aresult, the communication link L1 is disconnected.

Thereafter, the MFP 10 executes the Listen-operation again (i.e., theportable device 50 executes the Poll-operation again). The MFP 10receives the activation command from the portable device 50 (S10) andsends an OK command to the portable device 50 (S14). As a result, acommunication link L2 is established between the MFP 10 and the portabledevice 50.

The sending flag is set at “1” when the first target data iscommunicated. In this case, the MFP 10 determines that the result of S18of FIG. 2 is YES, executes the negotiation subsequently, and theninforms the portable device 50 of that the MFP 10 executes data sending(S30). The MFP 10 sends the second target data to the portable device 50(S32). In this case, the MFP 10 sets the sending flag at “0” and thecommunication complete flag at “0” (S40). The MFP 10 then receives thedeactivation command from the portable device 50 (S42) and sends an OKcommand to the portable device 50 (S44). As a result, the communicationlink L2 is disconnected.

As described above, the P2P-mode is a mode for bidirectionalcommunication. Therefore, considered is a configuration in which boththe first and second target data are communicated using the samecommunication link L1. However, there is a possibility that the portabledevice 50 cannot appropriately execute bidirectional communication inaccordance with the P2P-mode. For example, there is a possibility thatan OS (Operating System) of the portable device 50 does not allow theoperation of receiving the second target data using the samecommunication link L1 to be performed after sending the first targetdata by using the communication link L1.

In view of these possibilities, in the present embodiment, the MFP 10disconnects the communication link L1 when receiving the first targetdata from the portable device 50 by using the communication link L1corresponding to the P2P, as shown in the case A1. Subsequently, the MFP10 reestablishes the communication link L2 corresponding to P2P andsends the second target data to the portable device 50 by using thecommunication link L2. Thus, even when the portable device 50 does notallow the execution of bidirectional communication according to theP2P-mode, the MFP 10 can appropriately communicate the first target dataand the second target data with the portable device 50 in accordancewith the P2P-mode, the second target data being generated by processingthe first target data.

(Case A2; FIG. 7)

A case A2 is different from the case A1 in that the MFP 10 executes thehardware-based disconnecting process (S38 of FIG. 2) in place of thesoftware-based disconnecting process.

In other words, the MFP 10 temporarily stops the operations of the NFCI/F 22 in the hardware-based disconnecting process. The MFP 10,therefore, does not send an OK command even when receiving theconfirming command from the portable device 50. The MFP 10 also does notsend an OK command even when receiving the deactivation command from theportable device 50. Consequently, the portable device 50 determines thissituation as a timeout, resulting in disconnecting the communicationlink L1. The other points of the case A2 are same as those of the caseA1. The same operations and effects as those of the case A1 can beobtained with the case A2 as well.

Note that the execution of the hardware-based disconnecting process forthe case A2 might require a long time for the NFC I/F 22 to recover.Therefore, from the aspect of expediting the process, it is preferredthat the software-based disconnecting process for the case A1 beexecuted. However, the hardware-based disconnecting process for the caseA2 can reliably disconnect the communication link L1. Thus, from theaspect of accomplishing reliable disconnection of the communicationlink, it is preferred that the hardware-based disconnecting process forthe case A2 be executed. With regard to the other cases as well (such asa case A4 shown in FIG. 4), either the software-based disconnectingprocess or the hardware-based disconnecting process may be adopteddepending on the aspect valued by the vendor or manufacturer of the MFP10.

(Case A3; FIG. 8)

In the case A3, the MFP 10 executes the Poll-operation (i.e., theportable device 50 executes the Listen-operation) and the portabledevice 50 can be operated according to the P2P-mode.

The MFP 10 sends the activation command to the portable device 50 (S112of FIG. 4) and receives an OK command from the portable device 50(S114). Consequently, a communication link L1 is established between theMFP 10 and the portable device 50.

In the case A3, the sending flag is set at “0” at the time of theestablishment of the communication link L1. In this case, the MFP 10determines that the result of S118 of FIG. 4 is NO, executes thenegotiation subsequently, and then informs the portable device 50 ofthat the MFP 10 executes data reception (S120). The MFP 10 receives thefirst target data from the portable device 50 (S122) and generates thesecond target data by processing the first target data (S124). In thiscase, the MFP 10 sets the sending flag at “1” and the communicationcomplete flag at “1” (S128).

Next, the MFP 10 executes the software-based disconnecting process(S138). In other words, the MFP 10 sends a deactivation command to theportable device 50 and receives an OK command from the portable device50. As a result, the communication link L1 is disconnected.

Thereafter, the MFP 10 executes the Poll-operation again (i.e., theportable device 50 executes the Listen-operation again). The MFP 10sends the activation command to the portable device 50 (S112) andreceives an OK command from the portable device 50 (S114). As a result,a communication link L2 is established between the MFP 10 and theportable device 50.

The sending flag is set at “1” when the first target data iscommunicated. In this case, the MFP 10 determines that the result ofS118 of FIG. 4 is YES, executes the negotiation subsequently, and theninforms the portable device 50 of that the MFP 10 executes data sending(S130). The MFP 10 sends the second target data to the portable device50 (S132). In this case, the MFP 10 sets the sending flag at “0” and thecommunication complete flag at “0” (S140). The MFP 10 then sends thedeactivation command to the portable device 50 (S142) and receives an OKcommand from the portable device 50 (S144). As a result, thecommunication link L2 is disconnected.

As well as with the case A3, the MFP 10 can appropriately communicatethe first target data and the second target data with the portabledevice 50 in accordance with the P2P-mode, the second target data beinggenerated by processing the first target data.

(Case A4; FIG. 9)

A case A4 is different from the case A3 in terms of the contents of thesoftware-based disconnecting process. Note that, once the communicationlink L1 is established, the MFP 10 starts the confirming command sendingprocess (S116). In other words, the MFP 10 sends the confirming commandto the portable device 50 and receives an OK command from the portabledevice 50.

In the software-based disconnecting process for the case A3, the MFP 10sends the deactivation command to the portable device 50 and receives anOK command from the portable device 50 (see FIG. 8). In thesoftware-based disconnecting process for the case A4, on the other hand,the MFP 10 ends the confirming command sending process (S138).Accordingly, the portable device 50 determines this situation as atimeout, resulting in disconnecting the communication link L1. The otherpoints are same as those of the case A3. The same operations and effectsas those of the case A3 can be obtained with the case A4 as well.

As described above, the MFP 10 may execute the hardware-baseddisconnecting process for temporarily stopping the operations of the NFCI/F 22 (S138). In this case as well, because the confirming command isnot sent to the portable device 50, the portable device 50 determinesthe situation as a timeout, resulting in disconnecting the communicationlink L1. This configuration can achieve the same operations and effects.

(Other Cases)

In the cases A1 to A4 shown in FIGS. 6 to 9, when establishing the firstcommunication link L1 and when establishing the second communicationlink L2, the MFP 10 is operated as the same device (i.e., as the Listendevice in FIGS. 6 and 7, and as the Poll device in FIGS. 8 and 9).However, for example, when establishing the first communication link L1the MFP 10 may be operated as the Listen device, and when establishingthe second communication link L2 the MFP 10 may be operated as the Polldevice. Furthermore, for example, when establishing the firstcommunication link L1 the MFP 10 may be operated as the Poll device, andwhen establishing the second communication link L2 the MFP 10 may beoperated as the Listen device.

Moreover, in the cases A1 to A4 shown in FIGS. 6 to 9, the MFP 10receives the first target data from the portable device 50 and sends thesecond target data to the portable device 50. In other words, the casesA1 to A4 correspond to the first to fifth examples relating to thetarget data. However, the MFP 10 may send the first target data to theportable device 50 and receive the second target data from the portabledevice 50. In other words, the sixth example relating to the target datamay be realized. In any of the cases the same operations and effects asthose of the cases A1 to A4 can be obtained.

(Case B1; FIG. 10)

In the case B1, the MFP 10 executes the Listen-operation (i.e., theportable device 50 executes the Poll-operation) and the portable device50 can be operated according to only the R/W mode and the CE-mode.Therefore, the MFP 10 is operated according to the CE-mode, and theportable device 50 is operated according to the R/W-mode.

The MFP 10 receives the activation command from the portable device 50(S10 of FIG. 2) and sends an OK command to portable device 50 (S62).Consequently, a communication link L1 is established between the MFP 10and the portable device 50.

In the case B1, the sending flag is set at “0” at the time of theestablishment of the communication link L1. In this case, the MFP 10determines that the result of S64 of FIG. 3 is NO, receives the firsttarget data from the portable device 50 (S66) and generates the secondtarget data by processing the first target data (S68). In this case, theMFP 10 sets the sending flag at “1” and the communication complete flagat “1” (S72).

Next, the MFP 10 executes the software-based disconnecting process(S80). In other words, the MFP 10 receives the deactivation command fromthe portable device 50 and sends an OK command to the portable device50. As a result, the communication link L1 is disconnected.

Next, the MFP 10 executes the operation controlling process (S82). Inother words, the MFP 10 does not send a response signal even whenreceiving a polling signal from the portable device 50 (i.e., the NFCI/F 22 does not execute the Listen-operation temporarily). The MFP 10does not send a polling signal to the portable device 50 (i.e., the NFCI/F 22 does not execute the Poll-operation temporarily). Consequently,the portable device 50 detects secession of the MFP 10. As a result,even when the MFP 10 and the portable device 50 remain close to eachother, the communication link L2 described hereinafter can appropriatelybe established.

Thereafter, the MFP 10 executes the Listen-operation again (i.e., theportable device 50 executes the Poll-operation again). The MFP 10receives the activation command from the portable device 50 (S10 in FIG.2) and sends an OK command to the portable device 50 (S62). As a result,a communication link L2 is established between the MFP 10 and theportable device 50.

The sending flag is set at “1” when the first target data iscommunicated. In this case, the MFP 10 determines that the result of S64of FIG. 3 is YES and sends the second target data to the portable device50 (S74). In this case, the MFP 10 sets the sending flag at “0” and thecommunication complete flag at “0” (S86). The MFP 10 then receives thedeactivation command from the portable device 50 (S88) and sends an OKcommand to the portable device 50 (S90). As a result, the communicationlink L2 is disconnected.

As described above, the R/W-mode and the CE-mode are the modes forunidirectional communication. Thus, both the first and second targetdata cannot be communicated using the same communication link L1. In thepresent embodiment, when the MFP 10 receives the first target data fromthe portable device 50 by using the communication link L1, as shown inthe case B1, the communication link L1 is disconnected. Next, the MFP 10reestablishes the communication link L2 and sends the second target datato the portable device 50 by using the communication link L2. Therefore,even when the MFP 10 and the portable device 50 are operated accordingto the R/W-mode and the CE-mode, the MFP 10 can appropriatelycommunicate the first target data and the second target data with theportable device 50, the second target data being generated by processingthe first target data. In other words, the MFP 10 can realize pseudobidirectional communication.

(Case B2; FIG. 11)

In the case B1, the MFP 10 executes the Poll-operation (i.e., theportable device 50 executes the Listen-operation) and the portabledevice 50 can be operated according to only the R/W mode and theCE-mode. Therefore, the MFP 10 is operated according to the R/W-mode andthe portable device 50 is operated according to the CE-mode.

The MFP 10 sends the activation command to the portable device 50 (S160of FIG. 5) and receives an OK command from portable device 50 (S162).Consequently, a communication link L1 is established between the MFP 10and the portable device 50.

In the case B2, the sending flag is set at “0” at the time of theestablishment of the communication link L1. In this case, the MFP 10determines that the result of S164 of FIG. 5 is NO and determines thatthe MFP 10 is to be operated according to the Reader-mode (S165). TheMFP 10 receives the first target data from the portable device 50 (S166)and generates the second target data by processing the first target data(S168). In this case, the MFP 10 sets the sending flag at “1” and thecommunication complete flag at “1” (S172).

Next, the MFP 10 executes the software-based disconnecting process(S180). In other words, the MFP 10 sends the deactivation command to theportable device 50 and receives an OK command from the portable device50. As a result, the communication link L1 is disconnected.

Next, the MFP 10 executes the operation controlling process (S182).Consequently, the portable device 50 detects a secession of the MFP 10.Thereafter, the MFP 10 executes the Poll-operation again (i.e., theportable device 50 executes the Listen-operation again). The MFP 10sends the activation command to the portable device 50 (S160) andreceives an OK command from the portable device 50 (S162). As a result,a communication link L2 is established between the MFP 10 and theportable device 50.

The sending flag is set at “1” when the first target data iscommunicated. In this case, the MFP 10 determines that the result ofS164 of FIG. 5 is YES and determines that the MFP 10 is to be operatedaccording to the Writer-mode (S173). The MFP 10 sends the second targetdata to the portable device 50 (S174). In this case, the MFP 10 sets thesending flag at “0” and the communication complete flag at “0” (S186).The MFP 10 then sends the deactivation command to the portable device 50(S188) and receives an OK command from the portable device 50 (S190). Asa result, the communication link L2 is disconnected.

The same operations and effects as those of the case B1 can be obtainedwith the case B2 as well. In other words, even when the MFP 10 and theportable device 50 are operated according to the R/W-mode and theCE-mode, the MFP 10 can realize pseudo bidirectional communication.

(Other Cases)

In the cases B1 and B2 shown in FIGS. 10 and 11, when establishing thefirst communication link L1 and when establishing the secondcommunication link L2, the MFP 10 is operated as the same device (i.e.,the Listen device in FIG. 10, the Poll device in FIG. 11). However, forexample, as shown in the case B3 of FIG. 12, when establishing the firstcommunication link L1 the MFP 10 may be operated as the Listen device(i.e., CE-Mode), and when establishing the second communication link L2the MFP 10 may be operated as the Poll device (i.e., Writer-Mode).Furthermore, for example, as shown in the case B4 of FIG. 12, whenestablishing the first communication link L1 the MFP 10 may be operatedas the Poll device (i.e., Reader-Mode), and when establishing the secondcommunication link L2 the MFP 10 may be operated as the Listen device(i.e., CE-Mode).

Moreover, in the cases B1 and B2 shown in FIGS. 10 and 11, the MFP 10receives the first target data from the portable device 50 and sends thesecond target data to the portable device 50. In other words, the casesB1 and B2 correspond to the first to fifth examples relating to thetarget data. However, as shown in the cases B5 to B8 of FIG. 12, the MFP10 may send the first target data to the portable device 50 and receivethe second target data from the portable device 50. In other words, thesixth example relating to the target data may be realized. In any of thecases the same operations and effects as those of the cases B1 and B2can be obtained.

(Corresponding Relationship)

The MFP 10 is an example of “a communication device”. The portabledevice 50 is an example of “an external device”. The activation commandis an example of “a first establishing command” and “a secondestablishing command” The deactivation command is an example of “adisconnecting command” The sending flag=1 is an example of “sendinginformation”. In the cases A1 to A4 of FIGS. 6 to 9, the P2P-mode is anexample of “a sending-mode” and “a receiving-mode”. In the case B1 ofFIG. 10, the CE-mode is an example of “a sending-mode” and “areceiving-mode”. In the case B2 of FIG. 11, the Writer-mode is anexample of “a sending-mode. In the case B2 of FIG. 11, the Reader-modeis an example of “a receiving-mode.

S10 and S14 of FIG. 2, S62 of FIGS. 3, S112 and S114 of FIG. 4, and S160and S162 of FIG. 5 are examples of “a first establishing step (and afirst establishing module)” and “a second establishing step (and asecond establishing module)”. S22 and S32 of FIGS. 2, S66 and S74 ofFIGS. 3, S122 and S132 of FIG. 4, and S166 and S174 of FIG. 5 areexamples of “a first communicating step (and a first communicatingmodule)” and “a second communicating step (and a second communicatingmodule)”. S38 of FIG. 2, S80 of FIG. 3, S138 of FIG. 4, and S180 of FIG.5 are examples of “a disconnecting step (and a disconnecting module)”.S38 of FIG. 2 is an example of “a first disconnecting method”. S138 ofFIG. 4 is an example of “a second disconnecting method”. S80 of FIG. 3is an example of “a first disconnecting method”. S180 of FIG. 5 is anexample of “a second disconnecting method”.

A confirming command responding process started at S16 of FIG. 2 is anexample of “a first confirming step”. A confirming command sendingprocess started at S116 of FIG. 4 is an example of “a second confirmingstep”. S82 of FIG. 3 and S182 of FIG. 5 are examples of “an operationcontrolling step”. S18 of FIG. 2, S64 of FIG. 3, S118 of FIG. 4 and S164of FIG. 5 are examples of “a determining step”. S28 and S36 of FIGS. 2,S72 and S78 of FIGS. 3, S128 and S136 of FIG. 4 and S172 and S178 ofFIG. 5 are examples of “a memory controlling step”. S20 of FIG. 2 andS120 of FIG. 4 are examples of “an informing step”. S165 and S173 ofFIG. 5 are examples of “a deciding step”. S24 of FIG. 2, S68 of FIG. 3,S124 of FIG. 4 and S168 of FIG. 5 are examples of “a processing step”.S22 of FIG. 2, S66 of FIG. 3, S122 of FIG. 4 and S166 of FIG. 5 areexamples of “a receiving step”. S32 of FIG. 2, S74 of FIG. 3, S132 ofFIG. 4 and S174 of FIG. 5 are examples of “a sending step”.

While specific embodiments of the present invention have been describedin detail above, such description is for illustrative purposes only andis not intended to limit the scope and claims of the invention.Techniques described in the claims of the invention include variousmodifications and changes made to the specific examples illustratedabove. Modifications according to the above embodiments are listedbelow.

(Modification 1)

The “communication device” is not limited to the multi-functionperipheral (i.e., the MFP 10) capable of executing the printing functionand the scanning function, and, therefore, may be a printer capable ofexecuting only the printing function out of the printing function andthe scanning function or may be a scanner capable of executing only thescanning function out of the printing function and the scanningfunction. The “communication device” may be a device that executes afunction different from the printing function and the scanning function(e.g., an image display function, a data calculation function) (e.g., aPC, server, portable terminal (cellular phone, smartphone, PDA, etc.)).In other words, the “communication device” includes various devicescapable of executing the NFC scheme communications.

(Modification 2)

The MFP 10 may not be able to use the P2P-mode and may be capable ofusing only the R/W-mode and the CE-mode. In this case, the CPU 32 mayexecute each of the processes shown in FIGS. 3 and 5 without executingthe processes shown in FIGS. 2 and 4. Furthermore, the MFP 10 may not beable to use the R/W-mode and the CE-mode and may be capable of usingonly the P2P-mode. In other words, the “communication device” may not beable to use all of the modes complying with the NFC standard and may becapable of using at least one of the modes.

(Modification 3)

In each of the embodiments described above, each of the processes shownin FIGS. 2 to 5 is realized by the software (i.e., the programs 36, 38),but at least one of the processes shown in FIGS. 2 to 5 may be realizedby hardware such as a logic circuit.

(Modification 4)

In the foregoing embodiment, a print executing unit 18 and a scanexecuting unit 20 are realized as a result of the controller 30executing the processes according to the program in a memory 34.Nevertheless, at least one unit of respective units 18 and 20 mayalternately be realized by a hardware resource such as a logic circuit.

What is claimed is:
 1. A non-transitory computer-readable recordingmedium storing computer-readable instructions for a communicationdevice, wherein the computer-readable instructions, when executed by aprocessor of the communication device, cause the communication device tofunction to: communicate a first establishing command with an externaldevice via a communication interface of the communication device, thefirst establishing command being for establishing a first communicationlink between the communication device and the external device accordingto a first communication scheme; after the first establishing commandhas been communicated, establish the first communication link; after thefirst communication link has been established, read communicationsetting information from a memory of the external device via thecommunication interface by using the first communication link, thecommunication setting information being for executing communication withthe external device according to a second communication scheme that isdifferent from the first communication scheme, and a communication speedaccording to the first communication scheme being slower than acommunication speed according to the second communication scheme; andafter the communication setting information has been read from thememory of the external device, write, in the memory of the externaldevice via the communication interface, a response indicating that thecommunication setting information has been read from the memory of theexternal device.
 2. The non-transitory computer-readable recordingmedium as in claim 1, wherein the first communication scheme is a NearField Communication (NFC) scheme.
 3. The non-transitorycomputer-readable recording medium as in claim 1, wherein thecomputer-readable instructions, when executed by the processor of thecommunication device, cause the communication device to further functionto: disconnect the first communication link after the communicationsetting information has been read from the external device; after thefirst communication link has been disconnected, communicate a secondestablishing command with the external device via the communicationinterface, the second establishing command being for establishing asecond communication link between the communication device and theexternal device according to the first communication scheme; and afterthe second establishing command has been communicated, establish thesecond communication link, wherein the response is written in the memoryof the external device via the communication interface by using thesecond communication link after the second communication link has beenestablished.